<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<body class="no-skin1">
<form class="layui-form head-form">
    <div style="width: 100%;height: 10px;background: #f6f6f6;"></div>
    <div>
        <table class="layui-hide" id="mjdhtable1" lay-filter="mjtable1"></table>
        <script type="text/html" id="zjtoolbar1">
            <div style="padding: 16px;display: flex;justify-content: space-between;">
                <div  style="font-weight: 700;font-size: 18px;">海外头程装箱清单</div>
            </div>
        </script>
    </div>
</form>



<script th:inline="javascript">
	/*<![CDATA[*/
	var infoItems=[[${infoItems}]];
	var infoMap=[[${infoMap}]];
	var infoItems=infoItems ?infoItems:[]
    let tablecolsNum1 = infoMap.numBox
	var tablecol1=[ [
		{align: 'center',field: 'serial', title: '操作', width: 100 ,fixed: 'left'}
		,{align: 'center',field: 'vDFilesDefault', title: '透明标附件', width: 100,fixed: 'left'}
		,{align: 'center',field: 'isSign', title: '透明标记', width: 100,fixed: 'left'}
        ,{align: 'center',field: 'commodityCode', title: '商品编码', width: 100,fixed: 'left'}
        ,{align: 'center',field: 'nameGoodsCn', title: '商品名称', width: 100,fixed: 'left'}
		,{align: 'center',field: 'nameGoodsCn', title: '商品品名(中文)', width: 100}
		,{align: 'center',field: 'codeGoodsHs', title: '海关编码', width: 100}
		,{align: 'center',field: 'nameMaterialCn', title: '商品材质(中文)', width: 100}
        ,{align: 'center',field: 'priceIn', title: '商品采购价（¥）', width: 100}
        ,{align: 'center',field: 'linkJP', title: '竞品链接', width: 100}
		,{align: 'center',field: 'sku', title: 'SKU', width: 110}
		,{align: 'center',field: 'asin', title: 'ASIN', width: 110}
        ,{align: 'center',field: 'fnsku', title: 'FNSKU', width: 110}
        ,{align: 'center',field: 'numPlanDeliver', title: '计划发货数量', width: 100}
        ,{align: 'center',field: 'numRealityDeliver', title: '实际发货数量', width: 100}

    ]]
    //根据coleSize编辑出多少个箱子
    for (let i = 0; i < tablecolsNum1; i++) {
        let  tableData = {
            "align": "center",
            "field": "numRealityDeliver"+(i+1),
            "title": "箱子"+(i+1),
            "width": 95,
        }
        tablecol1[0].push(tableData);
    }



	var $,layer,form,table,nid,noTable;
    layui.use(['laydate','form','layer','jquery','util','element','upload','table'], function () {
		$ = layui.$, layer = layui.layer, form = layui.form, laydate = layui.laydate, util = layui.util, element = layui.element, upload = layui.upload, table = layui.table;

        if (tablecolsNum1 != 0) {
            infoItems.map((n, m) => {
                //将箱子数据赋值
                let ss = n.boxList.slice(1,n.boxList.length-1)
                let aa =  ss.split(",");
                for (let j = 0; j < aa.length; j++) {
                    let numRe = 'numRealityDeliver'+(j+1)
                    n[numRe] = aa[j]==0?"":aa[j]
                }
                if (n.serial == "箱重(kg)") {
                    n.serial = "箱重(lb)"
                    for (let i = 0; i <= tablecolsNum1; i++) {
                        let numRe = 'numRealityDeliver' + i
                        if (n[numRe] != undefined && n[numRe] != '') {
                            n[numRe] = (n[numRe] * 2.205).toFixed(2)
                        }
                    }
                }
                if (n.serial == "箱规长(cm)") {
                    n.serial = "箱规长(in)"
                    for (let i = 0; i <= tablecolsNum1; i++) {
                        let numRe = 'numRealityDeliver' + i
                        if (n[numRe] != undefined && n[numRe] != '') {
                            n[numRe] = (n[numRe] * 0.3937008).toFixed(2)
                        }
                    }
                }
                if (n.serial == "箱规宽(cm)") {
                    n.serial = "箱规宽(in)"
                    for (let i = 0; i <= tablecolsNum1; i++) {
                        let numRe = 'numRealityDeliver' + i
                        if (n[numRe] != undefined && n[numRe] != '') {
                            n[numRe] = (n[numRe] * 0.3937008).toFixed(2)
                        }
                    }
                }
                if (n.serial == "箱规高(cm)") {
                    n.serial = "箱规高(in)"
                    for (let i = 0; i <= tablecolsNum1; i++) {
                        let numRe = 'numRealityDeliver' + i
                        if (n[numRe] != undefined && n[numRe] != '') {
                            n[numRe] = (n[numRe] * 0.3937008).toFixed(2)
                        }
                    }
                }
                if (n.serial == "抛重(kg)") {
                    n.serial = "抛重(lb)"
                    for (let i = 0; i <= tablecolsNum1; i++) {
                        let numRe = 'numRealityDeliver' + i
                        if (n[numRe] != undefined && n[numRe] != '') {
                            n[numRe] = (n[numRe] * 2.205).toFixed(2)
                        }
                    }
                }
            })
        }
        // 初始化表格
		$.tablelist.init({
			elem: '#mjdhtable1'
			, data: infoItems
			, page: false
			, even: true
			, limit: 10000
			, totalRow: false
			, cols: tablecol1
			, toolbar: '#zjtoolbar1'
			, height: '550'
            , done: function (res, curr, count) {
                // $('th').css({ 'background-color': '#BCD2EE', 'color': 'black' });//设置th颜色
                //更新装箱清单样式
                var that = this.elem.next();
                res.data.forEach(function (item, index) {
                    if (item.scrapData == "1" && item.serial != "合计") {
                        var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']").css("background-color", '#e5f3fe');
                    } else {
                        var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']").css("background-color", 'white');
                    }
                })
            }
		});
	})

</script>

</body>
</html>